<?php
// $Id$

/**
 * @file
 * Implementation of round class
 * @TODO Use drupal errors
 */
 
/**
 * Class to represent a round, only loads the round details for read access
 */
class archeryRound {
  //Database fields
	var $rid, $name, $indoor, $rh, $ch, $mrc, $mcc, $frc, $fcc;
	
	/** Constructor
	 * Retrieves round information from the database
	 * @param $r Round ID 
	 */
	function archeryRound($r) {
		list($this->rid, $this->name, $this->indoor, $this->rh, $this->ch, $this->mrc, $this->mcc, $this->frc, $this->fcc) = $this->getRound($r);
	}
	
	/** Get the round data
	 * @param $rid ID of round shot
	 * @return Array of round data
	 */
	private static function getRound($rid) {
		//Get the round data
		$result = db_fetch_array(db_query('SELECT * FROM {round} WHERE `rid` = :rid', array(':rid' => $rid));
		//Check the round exists
		if(!isset($result['rid']) throw new Exception("Round not loaded, check the ID is correct.");
		return $result;
	}
}
